package com.dingding.special.user.deposit.dao.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.dingding.common.core.base.dao.impl.BaseDaoImpl;
import com.dingding.common.core.beans.special.Specialdepositrecord;
import com.dingding.special.user.deposit.dao.IUserDepositDao;
import com.dingding.special.user.deposit.sql.DepositSQL;

/**
 * 
 * @ClassName: UserDepositDaoImpl 
 * @Description: 用户提现DAO实现类 
 * @author YHQ
 * @date 2016年8月18日 下午9:38:07
 * @since V2.4.0
 * 
 */
@SuppressWarnings("deprecation")
@Component("userDepositDao")
public class UserDepositDaoImpl extends BaseDaoImpl<Specialdepositrecord> implements IUserDepositDao{

	private Logger log = Logger.getLogger(this.getClass());
	
	/**
	 * 
	 * @Title: addSpecialDepositRecord 
	 * @Description: 添加一条提现记录 
	 * @param @param specialdepositrecord
	 * @param @return    设定文件 
	 * @author YHQ 
	 * @since V2.4.0
	 * @return boolean    返回类型
	 * 
	 */
	@Override
	@Transactional(propagation=Propagation.REQUIRED)
	public boolean addSpecialDepositRecord(Specialdepositrecord specialdepositrecord) {
		
		try {
			super.save(specialdepositrecord);
			return true;
		} catch (Exception e) {
			log.error("添加一条提现记录时出现异常   类："+this.getClass()+" addSpecialDepositRecord()", e);
		}
		
		return false;
	}

	
	/**
	 * 
	 * @Title: getSpecialDepositRecord 
	 * @Description: 获取提现列表 
	 * @param userId 用户Id
	 * @author YHQ 
	 * @since V2.4.0
	 * @return List<Specialdepositrecord>    返回类型
	 * 
	 */
	@SuppressWarnings("unchecked")
	@Override
	@Transactional(readOnly=true)
	public List<Specialdepositrecord> getSpecialDepositRecord(String userId,Integer pageIndex,Integer pageSize) {
		
		try {
			
			return (List<Specialdepositrecord>) super.listSqlFreeObject(DepositSQL.GET_DEPOSIT_LIST, Specialdepositrecord.class, userId,(pageIndex - 1) * pageSize,pageSize);
		} catch (Exception e) {
			log.error("获取提现列表时出现异常   类："+this.getClass() + " getSpecialDepositRecord()", e);
		}
		
		return null;
	}

}
